#ifndef CPCAPSENDER_H
#define CPCAPSENDER_H

#include "pcaphandle.h"
#include "pcappacket.h"

class CPCapSender : public QObject
{
    Q_OBJECT
    Q_PROPERTY(CPCapHandle *handle READ handle WRITE setHandle NOTIFY handleChanged)
public:
    explicit CPCapSender(QObject *parent = Q_NULLPTR);
    ~CPCapSender();

    CPCapHandle *handle() const;
    void setHandle(CPCapHandle *handle);

    Q_INVOKABLE bool open(CPCapDev *dev);
    Q_INVOKABLE void close();

    Q_INVOKABLE bool sendPacket(CPCapPacket *packet);

Q_SIGNALS:
    void handleChanged();

    void opened();
    void closed();
    void finished();
    void error(QString err);

private:
    void *m_pcap = NULL;
    CPCapHandle *m_handle = Q_NULLPTR;
};

#endif // CPCAPSENDER_H
